<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
  <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
  <link rel="shortcut icon" href="/favicon.ico">
  <!-- 标题 -->
  <title>西安科技大学计算机学院互助圈 - 用户登录</title>
  <!-- 导入CSS -->
  <link href="./dist/css/tabler.min.css?1674944402" rel="stylesheet"/>
  <link rel="stylesheet" href="./dist/css/jquery.toast.css">
  <!-- 核心优化：背景样式 -->
  <style>
    :root {
      --primary-color: #4A90E2;
      --hover-color: #357ABD;
      /* 新增：背景辅助色，低饱和更显高级 */
      --bg-color-1: #e6f7ff;
      --bg-color-2: #f0f7ff;
      --float-element-color: rgba(74, 144, 226, 0.1);
    }

    body {
      /* 优化1：替换高饱和撞色渐变，改用低饱和蓝-青渐变，贴合科技+校园调性 */
      background: linear-gradient(135deg, var(--bg-color-1), var(--bg-color-2), #f5f9ff);
      background-size: 400% 400%;
      /* 优化2：减缓渐变动画速度，更显沉稳 */
      animation: gradientBG 20s ease infinite;
      min-height: 100vh;
      /* 新增：轻微网格纹理，提升背景质感（不干扰前景） */
      background-image:
              linear-gradient(rgba(160, 197, 232, 0.05) 1px, transparent 1px),
              linear-gradient(90deg, rgba(160, 197, 232, 0.05) 1px, transparent 1px);
      background-size: 20px 20px;
    }

    @keyframes gradientBG {
      0% {
        background-position: 0% 50%;
      }
      50% {
        background-position: 100% 50%;
      }
      100% {
        background-position: 0% 50%;
      }
    }

    .card {
      border: none;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
      border-radius: 16px;
      transition: all 0.3s ease;
      background: rgba(255, 255, 255, 0.95); /* 优化：提升卡片不透明度，与新背景更融合 */
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border: 1px solid rgba(220, 235, 250, 0.5); /* 优化：替换深色边框为浅蓝边框，更协调 */
      box-shadow: 0 8px 32px 0 rgba(160, 197, 232, 0.15); /* 优化：阴影色改为浅蓝，更柔和 */
    }

    .card:hover {
      transform: translateY(-5px);
      box-shadow: 0 15px 35px rgba(160, 197, 232, 0.2);
    }

    .form-control {
      border-radius: 8px;
      padding: 12px;
      border: 1px solid #e0e0e0;
      transition: all 0.3s ease;
    }

    .form-control:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    }

    .btn-primary {
      background-color: var(--primary-color);
      border: none;
      border-radius: 8px;
      padding: 12px;
      font-weight: 500;
      transition: all 0.3s ease;
    }

    .btn-primary:hover {
      background-color: var(--hover-color);
      transform: translateY(-1px);
    }

    .card-body {
      padding: 40px;
    }

    .text-center.mb-4 img {
      margin-bottom: 20px;
      transition: all 0.3s ease;
    }

    .text-center.mb-4 img:hover {
      transform: scale(1.05);
    }

    .form-label {
      font-weight: 500;
      color: #4a5568;
    }

    .text-muted {
      /* 优化：调整底部文字颜色，与新背景适配 */
      color: rgba(80, 100, 120, 0.7) !important;
    }

    .text-muted a {
      color: var(--primary-color); /* 优化：链接色改为主题色，更统一 */
      font-weight: 500;
    }

    .text-muted a:hover {
      color: var(--hover-color);
    }

    .input-group-text {
      background: transparent;
      border-left: none;
    }

    .input-group-flat .form-control {
      border-right: none;
    }

    @media (max-width: 768px) {
      .card-body {
        padding: 25px;
      }
    }

    /* 优化3：浮动背景元素升级 */
    .bg-animation {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -1;
      overflow: hidden;
    }

    .bg-animation li {
      position: absolute;
      display: block;
      list-style: none;
      /* 优化：替换单一圆形，增加几何多样性（圆角矩形、纤细椭圆） */
      border-radius: 8px; /* 圆角矩形 */
      background: var(--float-element-color);
      /* 优化：增加元素透明度层级，更有层次感 */
      opacity: 0.7;
      /* 优化：减缓运动速度，避免杂乱 */
      animation: animate 25s linear infinite;
      bottom: -150px;
    }

    /* 优化：浮动元素差异化，避免单调 */
    .bg-animation li:nth-child(1) {
      left: 25%;
      width: 80px;
      height: 30px; /* 矩形 */
      animation-delay: 0s;
      animation-duration: 22s;
    }

    .bg-animation li:nth-child(2) {
      left: 10%;
      width: 25px;
      height: 25px; /* 小正方形 */
      border-radius: 6px;
      animation-delay: 2s;
      animation-duration: 18s;
      opacity: 0.5;
    }

    .bg-animation li:nth-child(3) {
      left: 70%;
      width: 60px;
      height: 20px; /* 扁矩形 */
      animation-delay: 4s;
      animation-duration: 25s;
    }

    .bg-animation li:nth-child(4) {
      left: 40%;
      width: 40px;
      height: 40px; /* 正方形 */
      border-radius: 10px;
      animation-delay: 0s;
      animation-duration: 20s;
      opacity: 0.6;
    }

    .bg-animation li:nth-child(5) {
      left: 65%;
      width: 70px;
      height: 25px; /* 扁矩形 */
      animation-delay: 0s;
      animation-duration: 15s;
    }

    /* 新增：右侧SVG插图颜色微调，与背景呼应 */
    .col-lg.d-none.d-lg-block img {
      filter: hue-rotate(10deg) saturate(90%);
    }

    @keyframes animate {
      0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 0.4;
      }
      50% {
        transform: translateY(-500px) rotate(180deg) scale(1.1); /* 优化：增加缩放变化，更灵动 */
        opacity: 0.7;
      }
      100% {
        transform: translateY(-1000px) rotate(360deg) scale(0.9);
        opacity: 0;
      }
    }
  </style>
</head>
<body class="d-flex flex-column">
<!-- 浮动背景元素（样式已优化） -->
<ul class="bg-animation">
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>

<!-- 正文（保持原有结构，仅背景关联样式优化） -->
<div class="page page-center">
  <div class="container container-normal py-4">
    <div class="row align-items-center g-4">
      <div class="col-lg">
        <div class="container-tight">
          <div class="text-center mb-4">
            <img src="./image/college-badge.png" height="70" alt="" >
          </div>
          <div class="card card-md">
            <div class="card-body">
              <h2 class="text-center mb-4">用户登录</h2>
              <form id="signInForm" method="get" autocomplete="off" novalidate>
                <div class="mb-3">
                  <label class="form-label required">用户名</label>
                  <input type="text" class="form-control" placeholder="请输入用户名" autocomplete="off" name="username" id="username">
                  <div class="invalid-feedback">用户名不能为空</div>
                </div>
                <div class="mb-2">
                  <label class="form-label required">
                    密码
                    <!-- <span class="form-label-description">
                      <a href="#">忘记密码</a>
                    </span> -->
                  </label>
                  <div class="input-group input-group-flat">
                    <input type="password" class="form-control"  placeholder="请输入密码"  autocomplete="off" name="password"
                           id="password">
                    <span class="input-group-text">
                            <a href="javascript:void(0);" id="password_a" class="link-secondary" title="显示密码" data-bs-toggle="tooltip"><!-- Download SVG icon from http://tabler-icons.io/i/eye -->
                              <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M22 12c-2.667 4.667 -6 7 -10 7s-7.333 -2.333 -10 -7c2.667 -4.667 6 -7 10 -7s7.333 2.333 10 7" /></svg>
                            </a>
                          </span>
                    <div class="invalid-feedback">密码不能为空</div>
                  </div>
                </div>
                <!-- <div class="mb-2">
                  <label class="form-check">
                    <input type="checkbox" class="form-check-input"/>
                    <span class="form-check-label">记住我</span>
                  </label>
                </div> -->
                <div class="form-footer">
                  <button id="submit" type="button" class="btn btn-primary w-100">登录</button>
                </div>
              </form>
            </div>
          </div>
          <div class="text-center text-muted mt-3">
            还没有注册吗? <a href="./sign-up.html" tabindex="-1">点击注册</a>
          </div>
        </div>
      </div>
      <div class="col-lg d-none d-lg-block">
        <img src="./dist/illustrations/undraw_joyride_hnno.svg" height="300" class="d-block mx-auto" alt="">
      </div>
    </div>
  </div>
</div>
</body>
<!-- 导入JS（保持不变） -->
<script src="./dist/js/jquery-3.6.3.min.js"></script>
<script src="./dist/js/tabler.min.js"></script>
<script src="./dist/js/jquery.toast.js"></script>
<script>
  $(function () {
    // 获取控件
    let usernameEl = $('#username');
    let passwordEl = $('#password');
    // 登录校验
    $('#submit').click(function () {
      let checkForm = true;
      // 校验用户名
      if (!usernameEl.val()) {
        usernameEl.addClass('is-invalid');
        checkForm = false;
      }
      // 校验密码
      if (!passwordEl.val()) {
        passwordEl.addClass('is-invalid');
        checkForm = false;
      }

      if (!checkForm) {
        return false;
      }

      // 构造数据
      let postData = {
        username : usernameEl.val(),
        password : passwordEl.val()
      };
      // 发送AJAX请求
      $.ajax({
        type : 'post',
        url  : 'user/login',
        contentType : 'application/x-www-form-urlencoded',
        data : postData,
        success: function(respData){
          if (respData.code == 0) {
            location.assign('/index.html');
          } else {
            $.toast({
              heading: '警告',
              text: respData.message,
              icon: 'warning'
            });
          }
        },
        error : function() {
          $.toast({
            heading: '错误',
            text: '访问出现问题，请与管理员联系.',
            icon: 'error'
          });
        }
      });
    });

    // 表单元单独检验
    $('#username, #password').on('blur', function () {
      if ($(this).val()) {
        $(this).removeClass('is-invalid');
        $(this).addClass('is-valid');
      } else {
        $(this).removeClass('is-valid');
        $(this).addClass('is-invalid');
      }
    });

    // 显示密码
    $('#password_a').click(function () {
      if(passwordEl.attr('type') == 'password') {
        passwordEl.attr('type', 'text');
      } else {
        passwordEl.attr('type', 'password');
      }
    });
  });
</script>
</html>